﻿using System;

using LoginServer.Manager;
using LoginServer.Networking.Packets;

namespace LoginServer.Networking.Handlers
{
    class SHANDLE_BAN_PLAYER : PacketHandler
    {
        public override void Handle(LoginServer.Virtual_Objects.Server.virtualServer Server)
        {
            int BanID = int.Parse(getNextBlock());
            int UserID = int.Parse(getNextBlock());
            string IP = getNextBlock();
            long ExpireDate = long.Parse(getNextBlock());

            Log.WriteLine("Ban Received from server: " + Server.getID() + " - " + Server.getName() + " for " + UserID);

            BanManager.add(BanID, UserID, IP, "");

            foreach (Virtual_Objects.Server.virtualServer _Server in ServerManager.getServers())
            {
                _Server.send(new SPACKET_BAN_PLAYER(BanID, UserID, IP, ""));
            }
            
            Log.WriteLine("Added Ban " + BanID + " to the Server Ban Manager");
        }
    }
}
